package com.dw.widget.slideshow2.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class AppConfig {
	private Context mContext;
	private SharedPreferences mPreferences;
	
	public AppConfig(Context context, String configName)
	{
		mContext = context;
		mPreferences = mContext.getSharedPreferences(configName, mContext.MODE_PRIVATE);
	}
	
	public String getString(String key)
	{
		return mPreferences.getString(key, "");
	}
	
	public int getInt(String key)
	{
		return mPreferences.getInt(key, Integer.MIN_VALUE);
	}
	
	public int getInt(String key, int defaule)
	{
		return mPreferences.getInt(key, defaule);
	}
	
	public boolean getBoolean(String key)
	{
		return mPreferences.getBoolean(key, false);
	}
	
	public boolean getBoolean(String key, boolean defaultValue)
	{
		return mPreferences.getBoolean(key, defaultValue);
	}
	
	public float getFloat(String key)
	{
		return mPreferences.getFloat(key, Float.MIN_VALUE);
	}
	
	public boolean putString(String key, String value)
	{
		return mPreferences.edit().putString(key, value).commit();
	}
	
	public boolean putInt(String key, int value)
	{
		return mPreferences.edit().putInt(key, value).commit();
	}
	
	public boolean putBoolean(String key, boolean value)
	{
		return mPreferences.edit().putBoolean(key, value).commit();
	}
	
	public boolean putFloat(String key, float value)
	{
		return mPreferences.edit().putFloat(key, value).commit();
	}
}
